<template>
	<view class="page-body">
		<view class="page-section ">
			<map style="width: 100%; height:100vh;" :latitude="latitude" :longitude="longitude" :markers="covers">
			</map>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude: '',
				longitude: '',
				indentNumber: '',
				covers: [],
				timer:null
			}
		},
		onUnload() {
			clearInterval(this.timer)
		},
		onHide() {
			clearInterval(this.timer)
		},
		onLoad(option) {
			if (option.indentNumber) {
				this.indentNumber = option.indentNumber
				this.getDetail()
			}
			this.timer = setInterval(()=>{
				this.getDetail()
			},2000)
			let that = this
			uni.getLocation({
				type: 'wgs84',
				success: function (res) {
					console.log('当前位置的经度：' + res.longitude);
					console.log('当前位置的纬度：' + res.latitude);
					that.latitude = res.latitude
					that.longitude = res.longitude
				}
			});

			
		},
		onShow() {

		},
		methods: {
			getDetail() {
				let data = {
					indentNumber: this.indentNumber
				}
				this.$Request.getT('/app/indent/userIndentMessage', data).then(res => {
					if (res.code === 0) {
						this.covers = [{
							id: 0,
							latitude: res.data.startLat,
							longitude: res.data.startLng,
							iconPath: 'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/huoyun/image/qi.png',
							width: 28,
							height: 40,
							callout: { //自定义标记点上方的气泡窗口 点击有效
								content: res.data.startAddress, //文本
								color: '#333333', //文字颜色
								fontSize: 10, //文本大小
								padding: 10, //附近留白
								borderRadius: 6, //边框圆角
								bgColor: '#FFFFFF', //背景颜色
								display: 'ALWAYS', //常显
							},
						},{
							id: 1,
							latitude: res.data.endLat,
							longitude: res.data.endLng,
							iconPath: 'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/huoyun/image/zd.png',
							width: 28,
							height: 40,
							callout: { //自定义标记点上方的气泡窗口 点击有效
								content: res.data.endAddress, //文本
								color: '#333333', //文字颜色
								fontSize: 10, //文本大小
								padding: 10, //附近留白
								borderRadius: 6, //边框圆角
								bgColor: '#FFFFFF', //背景颜色
								display: 'ALWAYS', //常显
							},
						},{
							id: 2,
							latitude: res.data.riderLocation.lat,
							longitude: res.data.riderLocation.lng,
							iconPath: 'https://yuexiaoda-1314351529.cos.ap-shanghai.myqcloud.com/huoyun/image/rider.png',
							width: 38,
							height: 34,
							// callout: { //自定义标记点上方的气泡窗口 点击有效
							// 	content: res.data.startAddress, //文本
							// 	color: '#333333', //文字颜色
							// 	fontSize: 10, //文本大小
							// 	padding: 10, //附近留白
							// 	borderRadius: 6, //边框圆角
							// 	bgColor: '#FFFFFF', //背景颜色
							// 	display: 'ALWAYS', //常显
							// },
						}]
					}
					uni.hideLoading()
				});
			},
		}
	}
</script>

<style lang="scss">
</style>